package cn.hanyx.coder.design.pattern.creational.factory.simple.demo03;

import cn.hanyx.coder.design.pattern.creational.factory.simple.demo01.*;

/**
 * RuleConfigParserFactory
 *
 * @author hanyx
 * @date 2020/07/14
 */
public class RuleConfigParserFactory {
    public static IRuleConfigParser createParse(String ruleConfigFileExtension) throws Exception {
        IRuleConfigParser parser = null;
        if ("json".equalsIgnoreCase(ruleConfigFileExtension)) {
            parser = new JsonRuleConfigParser();
        } else if ("xml".equalsIgnoreCase(ruleConfigFileExtension)) {
            parser = new XmlRuleConfigParser();
        } else if ("yaml".equalsIgnoreCase(ruleConfigFileExtension)) {
            parser = new YamlRuleConfigParser();
        } else if ("properties".equalsIgnoreCase(ruleConfigFileExtension)) {
            parser = new PropertiesRuleConfigParser();
        }
        return parser;
    }
}
